home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 187_01 / dirnxt.c < prev    next >
C/C++ Source or Header  |  1986-02-19  |  2KB  |  46 lines

  1. /*@*****************************************************/
  2. /*@                                                    */
  3. /*@ dirnxt - search directory for next matching entry. */
  4. /*@                                                    */
  5. /*@   Usage:     dirnxt(dta);                          */
  6. /*@       where dta is the DTA specified in a previous */
  7. /*@            call to dirfst().                       */
  8. /*@                                                    */
  9. /*@       returns a pointer to the file in the DTA.    */
  10. /*@                                                    */
  11. /*@           an extern of dirret has the last return  */
  12. /*@               code from DOS.                       */
  13. /*@                                                    */
  14. /*@       NOTE:  You must not tamper with the DTA      */
  15. /*@           between dirfst() and dirnxt() calls.     */
  16. /*@                                                    */
  17. /*@*****************************************************/
  18.  
  19.  
  20. extern unsigned _rax, _rbx, _rcx, _rdx, _rsi, _rdi, _res, _rds;
  21. extern char _carryf, _zerof;
  22.  
  23. extern int dirret;
  24.  
  25. char *dirnxt(dta)
  26. char *dta;
  27. {
  28.     int sav_carry, sav_rax;
  29.  
  30.     savedta();                /* save old dta */
  31.     setdta(dta);            /* use caller's area */
  32.     dirret = 0;                /* clear return code */
  33.  
  34.     _rax = 0x4f00;            /* DOS find first function */
  35.     _doint(0x21);            /* call DOS */
  36.     sav_carry = _carryf;
  37.     sav_rax = _rax;
  38.     restdta();                /* reset to DOS's DTA */
  39.     if (!sav_carry)
  40.         return &dta[30];
  41.     else {
  42.         dirret = sav_rax;        /* save return code */
  43.         return 0;
  44.     }
  45. }
  46.